# -*- coding: utf-8 -*-
"""
@Time ： 2025/4/12 11:26
@Auth ： Martina Luo
@Function ：元组,与列表的区别是元素不能修改。查、相加、截取
"""
tup1 = ()
tup1 = (1,2,'3')
# tup1 = (1,)
# print(tup1)
# print(type(tup1))

# tup2 = (1)
# print(tup2)
# print(type(tup2))

# 获取值
print(tup1[0])
print(tup1[-1])
print(len(tup1))

# 相加
tup1 = tup1 + tup1
print(tup1)

# 截取
tup1 = tup1[:]
print(tup1)

print(tup1[1:])
print(tup1[1:-1])
print(tup1[-2:])

# 遍历
for i in tup1:
    print(i,end="\t")
print()
for i in range(len(tup1)):
    print(i,end="\t")

